#! /bin/bash

usage="$0 --help \t\t - shows this\n$0 [-p] vs vt\t\t\t - clones version <vs> to <vt>, if '-p' is set, only clones settings files" 

case $1 in '-h'|'-help'|'--help')
	echo  -e $usage
	exit;;
esac
[[ $1 == '-p' ]] && { only_settings=1; shift; }
[[ -n $1 ]] || { echo -e $usage; exit 1; }
[[ -d $SYSCPAR_ROOT/code/$1 ]] || { echo "$1 is not a version directory"; exit 1; }
command="s|$1|$2|g"
cd $SYSCPAR_ROOT/code
[[ -n $only_settings ]] || cp -r ./$1 $2
sed $command ./$1/.cproject > ./$2/.cproject
sed $command ./$1/.project > ./$2/.project
[[ -n $only_settings ]] && cp -r ./$1/.settings ./$2/.settings
[[ -n $only_settings ]] || find ./$2 -name '.svn' -print | xargs /bin/rm -rf

